<%@ page import="cn.zzszxyy.hr.comm.Global" %><%--
  作者:张伟

  联系:adamzzww@163.com
  时间:2016-11-29
  说明:调动部门
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>调动用户部门</title>
    <%@include file="../../desktop/include/assets.jsp" %>
    <link href="<%=_asset_path%>/zui-1.5.0/lib/datetimepicker/datetimepicker.min.css" rel="stylesheet">
    <script type="text/javascript" src="<%=_asset_path%>/zui-1.5.0/lib/datetimepicker/datetimepicker.min.js"></script>
    <%
        String url = request.getContextPath() + Global.PATH;
    %>

    <style>
        .infoForm {
            padding: 20px
        }
    </style>
</head>
<body>
<div class="infoForm">
    <form id="editForm" name="editForm" class="form-horizontal form-condensed" role="form" method="post"
          action="<%=url%>/deptTrans">
        <div class="form-group">
            <label class="col-xs-3 control-label required" for="transDate">调动日期</label>
            <div class="col-xs-6">
                <input class="form-control form-date" type="text" name="transDate" id="transDate" placeholder="调动日期"
                       title="调动日期">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">当前所属部门</label>
            <div class="col-xs-6">
                <c:if test="${!empty deptList }">
                    <c:forEach items="${deptList }" var="dept">
                        <c:if test="${dept.deptId == entity.curDept}">
                            <label class="form-control">${dept.deptName}</label>
                        </c:if>
                    </c:forEach>
                </c:if>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">调至部门</label>
            <div class="col-xs-6">
                <select name="toDept" id="toDept" class="form-control">
                    <c:if test="${!empty deptList }">
                        <c:forEach items="${deptList }" var="dept">
                            <c:if test="${dept.deptId != entity.curDept}">
                                <option value="${dept.deptId}">${dept.deptName}</option>
                            </c:if>
                        </c:forEach>
                    </c:if>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label required" for="reason">调动原因</label>
            <div class="col-xs-6">
                <textarea rows="4" name="reason" id="reason" class="form-control"></textarea>
            </div>
        </div>

        <hr/>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" id="saveBtn" class="btn btn-primary" value="保存" data-loading="稍候...">
                <c:if test="${!empty entity.employeeId }">
                    <input type="hidden" name="employeeId" value="${entity.employeeId}">
                </c:if>
                <input type="hidden" name="fromDept" value="${entity.curDept}">
            </div>
        </div>
    </form>
</div>

<script>

    $(".form-date").datetimepicker({
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
        language: 'zh-CN', //汉化
        autoclose: true, //选择日期后自动关闭
        format: "yyyy-mm-dd",
    });

    $(function () {
        var validate = $("#editForm").validate({
            //debug: true, //调试模式取消submit的默认提交功能
            rules: {
                transDate: {
                    required: true,
                },
                reason: {
                    required: true,
                }
            },
            messages: {
                transDate: {
                    required: "请输入日期"
                }
            },
            submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form
                $.ajax({
                    url: form.action,
                    type: form.method,
                    data: $(form).serialize(),
                    success: function (data) {
                        // 提交表单
                        if (data == "success") {
                            alert("提交成功！");
                            //$("#editForm")[0].reset();
                            window.parent.location.reload();
                        } else {
                            alert("提交失败！");
                        }
                    }
                });
            },
        });
    });
</script>

</body>
</html>
